package com.car.service.Impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import com.car.entity.Vehiclemotioncar;
import com.car.mapper.VehiclemotioncarMapper;
import com.car.page.Page;
import com.car.service.VehiclemotioncarService;
import com.car.vo.VehiclemotioncarVo;
@Service
public class VehiclemotioncarServiceImpl implements VehiclemotioncarService {
	@Autowired
	VehiclemotioncarMapper vehiclemotioncarMapper;

	@Override
//	@CacheEvict(value="vehi",allEntries =true)
	@Cacheable(value="vehi",key="#root.methodName")
	public Page<VehiclemotioncarVo> selectAllShunCar(String takeCarCity, String carCity, Integer pageNo,
			Integer pageSize) {
		// TODO Auto-generated method stub
		Page<VehiclemotioncarVo> page = new Page<VehiclemotioncarVo>(pageNo,pageSize);
		System.out.println("开始查询");
		/*try { 
			Thread.sleep(3*1000l);
		} catch (InterruptedException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
		List<VehiclemotioncarVo> lists = vehiclemotioncarMapper.selectAllShunCar(takeCarCity, carCity, (pageNo-1)*page.getPageSize(),  page.getPageSize());
	
			page.setTotalRow(vehiclemotioncarMapper.countsAllShunCar(takeCarCity, carCity));
			System.out.println("查询结束");
		
		
		page.setList(lists);
		return page;
	}

	@Override
	public VehiclemotioncarVo selectAllShunCarInfos(String hitchingrideId) {
		// TODO Auto-generated method stub
		return vehiclemotioncarMapper.selectAllShunCarInfos(hitchingrideId);
	}

	@Override
	public VehiclemotioncarVo selectById(Integer hitchingrideId) {
		// TODO Auto-generated method stub
		return vehiclemotioncarMapper.selectById(hitchingrideId);
	}

	@Override
	public int addVehicle(Vehiclemotioncar vehi) {
		// TODO Auto-generated method stub
		return vehiclemotioncarMapper.addVehicle(vehi);
	}

	@Override
	public int updVehicle(Vehiclemotioncar vehi) {
		// TODO Auto-generated method stub
		return vehiclemotioncarMapper.updVehicle(vehi);
	}

	@Override
	public int delVehicle(Integer id) {
		// TODO Auto-generated method stub
		return vehiclemotioncarMapper.delVehicle(id);
	}


}
